var net = require('net');

var server = net.createServer(function(socket) {
    console.log('客户端已连接');

    socket.on('data', function(data) {
        console.log('来自客户端数据 ', data.toString());
    });

    socket.on('end', function(data) {
        console.log('服务端接到客户端断开连接');
    });

    socket.write('Hello\r\n');
});

server.listen(8080, function() {
    console.log('开启服务');
})